package xj.graph2d.graph;

/**
 * An interface for methods that perform attribute value conversions.
 * 
 */
public interface AttributeHandler {

  /**
   * Returns the attribute conversion type for the supplied attribute name
   * and element type..
   * 
   * @param elemType
   *                the element type
   * @param attrName
   *                the attribute name
   * @return the currently associated attribute type
   * 
   */
  public int attributeType(int elemType, String attrName);

  /**
   * Convert the supplied value to a string. How to convert the value is
   * based on the type, name and attrtype information supplied. Note: this
   * method really could be declared static except that it hides the
   * instance method declared in the AttributeHandler interface and a
   * class method cannot hide an instance method.
   * 
   * @param elemType
   *                the element type to which the named attribute applies
   * @param name
   *                the name of the attribute
   * @param value
   *                the object value to be converted to a string
   * @param convType
   *                the object-to-string conversion type of the value
   *                object
   * @return a string representation of the supplied value
   */
  public String convertValue(int elemType, String name, Object value,
      int convType);

  /**
   * Convert the supplied string value to the appropriate Object. How to
   * convert the value is based on the type, name and attrtype information
   * supplied. Note: this method really could be declared static except
   * that it hides the instance method declared in the AttributeHandler
   * interface and a class method cannot hide an instance method.
   * 
   * @param elemType
   *                the element type to which the named attribute applies
   * @param name
   *                the name of the attribute
   * @param value
   *                the string value to be converted to an object
   * @param convType
   *                the string-to-object conversion type of the value
   *                object
   * @return an object representation of the supplied value
   */
  public Object convertStringValue(int elemType, String name,
      String stringValue, int convType);

  /**
   * Make a copy of the supplied value. How to copy the value is based on
   * the type, name and attrtype information supplied. Note: this method
   * really could be declared static except that it hides the instance
   * method declared in the AttributeHandler interface and a class method
   * cannot hide an instance method.
   * 
   * @param elemType
   *                the element type to which the named attribute applies
   * @param name
   *                the name of the attribute
   * @param value
   *                the attribute value to be copied
   * @param convType
   *                the conversion type of the value object
   * @return a copy of the supplied value
   */
  public Object copyValue(int elemType, String name, Object value, int convType);
}
